:root {
  --ink: #171716;
  --muted: #6b6861;
  --line: rgba(23, 23, 22, 0.12);
  --accent: #315765;
  --accent-2: #b88a42;
  --danger: #c14343;
  --paper: #f1f3ed;
  --panel: #fafaf7;
  --success: #22c55e;
  --warning: #f59e0b;
}

.admin-page {
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(251, 250, 246, 0.95), rgba(245, 247, 243, 0.98));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.admin-page [hidden],
.admin-view {
  display: none !important;
}

.admin-page button,
.admin-page input,
.admin-page select,
.admin-page textarea {
  font: inherit;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(24, 25, 23, 0.04);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #2a4a57);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 900;
}

.brand-lockup strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.brand-lockup small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

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

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.sync-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  background: var(--success);
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
}

.admin-main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px;
}

.admin-login {
  display: grid;
  min-height: calc(100vh - 120px);
  place-items: center;
}

.login-card,
.manager-panel,
.admin-summary {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(24, 25, 23, 0.08);
}

.login-card {
  width: min(460px, 90%);
  padding: 40px;
  text-align: center;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card h1 {
  margin: 20px 0 10px;
  font-size: 26px;
  font-weight: 700;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-mark {
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  color: #ffe3a2;
  background: linear-gradient(135deg, var(--ink), #2a2a28);
  border-radius: 16px;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.admin-top-actions,
.editor-actions,
.status-row,
.panel-title,
.section-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-top-actions,
.status-row,
.panel-title,
.section-tools {
  justify-content: space-between;
}

.admin-summary {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(400px, 2fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 24px;
  padding: 28px;
}

.admin-summary h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.admin-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 0;
}

.summary-grid div {
  position: relative;
  padding: 20px;
  background: linear-gradient(145deg, #f8faf7, #f0f2ed);
  border-radius: 12px;
  text-align: center;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.summary-grid div:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(49, 87, 101, 0.08);
}

.summary-grid dt {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-grid dd {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 32px;
  font-weight: 700;
}

.summary-grid dd::after {
  content: "";
  position: absolute;
  top: -20px;
  right: -20px;
  width: 60px;
  height: 60px;
  background: rgba(49, 87, 101, 0.04);
  border-radius: 50%;
}

.admin-view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.admin-view-tabs button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  color: var(--muted);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
}

.admin-view-tabs button .tab-icon {
  font-size: 18px;
}

.admin-view-tabs button .tab-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #f0f1ed;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.admin-view-tabs button:hover {
  background: #f5f7f3;
  border-color: rgba(49, 87, 101, 0.1);
}

.admin-view-tabs button:hover .tab-shortcut {
  background: rgba(49, 87, 101, 0.1);
  color: var(--accent);
}

.admin-view-tabs button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #2a4a57);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(49, 87, 101, 0.3);
}

.admin-view-tabs button.is-active .tab-shortcut {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.admin-view.is-active {
  display: grid !important;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
}

.admin-view[data-view="content"].is-active,
.admin-view[data-view="guide"].is-active,
.admin-view[data-view="data"].is-active {
  grid-template-columns: 1fr;
}

.manager-panel {
  padding: 24px;
}

.product-manager {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-title {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.compact {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.admin-page label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #34322e;
}

.admin-page input,
.admin-page select,
.admin-page textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.admin-page textarea {
  resize: vertical;
  line-height: 1.6;
}

.admin-page input:focus,
.admin-page select:focus,
.admin-page textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(49, 87, 101, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.span-2 {
  grid-column: span 2;
}

.check-line {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check-line input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.filter-stack,
.category-list,
.product-list,
.row-editor {
  display: grid;
  gap: 12px;
}

.filter-stack {
  margin-bottom: 20px;
}

.category-list,
.product-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.category-row,
.product-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-row:hover,
.product-row:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(49, 87, 101, 0.08);
}

.category-row.is-active,
.product-row.is-active {
  border-color: var(--accent);
  background: rgba(49, 87, 101, 0.05);
}

.category-row img,
.product-row img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  background: #f0f0eb;
}

.category-row strong,
.product-row strong {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-row small,
.product-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.row-badges small {
  padding: 3px 10px;
  color: var(--accent);
  background: #eef3ee;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.row-badges .is-edited {
  color: #7b4d13;
  background: #f3e5c5;
}

.row-badges .is-missing {
  color: var(--danger);
  background: #f6ded8;
}

.image-helper,
.admin-columns {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(340px, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.image-helper img,
.image-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-height: 340px;
  overflow-y: auto;
}

.compact-grid {
  grid-template-columns: repeat(5, 1fr);
}

.asset-button {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.asset-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.asset-button.is-active {
  border-color: var(--accent);
  background: rgba(49, 87, 101, 0.06);
}

.asset-button img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #f0f0eb;
}

.asset-button span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-tools {
  margin: 20px 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-tools h3 {
  margin: 0;
  font-size: 16px;
}

.spec-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: all 0.2s;
}

.spec-row:hover {
  border-color: rgba(49, 87, 101, 0.2);
}

.icon-action {
  width: 42px;
  height: 42px;
  color: var(--muted);
  background: #f5f5f0;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-action:hover {
  background: #fff;
  color: var(--accent);
  transform: scale(1.05);
}

.json-box {
  min-height: 400px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 13px;
}

.json-box.small {
  min-height: 200px;
}

.status-row {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-status {
  min-height: 26px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.admin-status.is-error {
  color: var(--danger);
}

.admin-status.is-success {
  color: var(--success);
}

.admin-status.is-warning {
  color: var(--warning);
}

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

.danger:hover {
  background: rgba(193, 67, 67, 0.1);
}

.drop-zone {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 24px;
  background: #f8fbf6;
  border: 2px dashed rgba(49, 87, 101, 0.25);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  background: #edf5ef;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(49, 87, 101, 0.1);
}

.drop-zone strong {
  font-size: 16px;
}

.drop-zone span {
  color: var(--muted);
  font-size: 13px;
}

.guide-panel ol {
  display: grid;
  gap: 14px;
  margin: 0;
  padding-left: 28px;
}

.guide-panel li {
  line-height: 1.7;
  font-size: 15px;
}

.guide-note {
  margin-top: 24px;
  padding: 20px;
  color: #433b2e;
  background: #fff7e7;
  border: 1px solid #ead7ae;
  border-radius: 12px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #f8faf7;
  border-bottom: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
}

.batch-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.batch-count {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}

.keyboard-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, #f8faf7, #f0f2ed);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.keyboard-hints .hint {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
}

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

.keyboard-hints kbd {
  display: inline-block;
  padding: 3px 8px;
  background: linear-gradient(135deg, #f5f5f5, #eee);
  border: 1px solid #ddd;
  border-radius: 5px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.keyboard-hints .hint-item:first-of-type kbd {
  background: linear-gradient(135deg, var(--accent), #2a4a57);
  color: #fff;
  border-color: var(--accent);
}

.quick-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: #fafaf7;
  border-bottom: 1px solid var(--line);
}

.quick-filters .filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.quick-filters .filter-tag {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
}

.quick-filters .filter-tag:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.group-filter {
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 12px;
}

.group-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 87, 101, 0.1);
}

.backup-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: #f0f8ff;
  border-bottom: 1px solid var(--line);
}

.backup-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: #2563eb;
}

.backup-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ccc;
}

.backup-indicator.is-active {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}

.backup-hint {
  font-size: 13px;
  color: var(--muted);
}

.backup-history {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.backup-history h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: #f9f8f3;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: all 0.2s;
}

.backup-item:hover {
  background: #f3f4ef;
}

.backup-title {
  font-weight: 600;
  font-size: 14px;
}

.backup-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.product-list::-webkit-scrollbar,
.category-list::-webkit-scrollbar,
.asset-grid::-webkit-scrollbar,
.backup-list::-webkit-scrollbar {
  width: 6px;
}

.product-list::-webkit-scrollbar-track,
.category-list::-webkit-scrollbar-track,
.asset-grid::-webkit-scrollbar-track,
.backup-list::-webkit-scrollbar-track {
  background: #f0f0eb;
  border-radius: 3px;
}

.product-list::-webkit-scrollbar-thumb,
.category-list::-webkit-scrollbar-thumb,
.asset-grid::-webkit-scrollbar-thumb,
.backup-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.product-list::-webkit-scrollbar-thumb:hover,
.category-list::-webkit-scrollbar-thumb:hover,
.asset-grid::-webkit-scrollbar-thumb:hover,
.backup-list::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

@media (max-width: 1200px) {
  .admin-summary,
  .admin-view.is-active,
  .image-helper,
  .admin-columns {
    grid-template-columns: 1fr;
  }

  .product-manager {
    position: static;
    max-height: none;
    flex-direction: column;
  }

  .category-list,
  .product-list {
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  .admin-topbar {
    padding: 12px 16px;
  }

  .brand-lockup small {
    display: none;
  }

  .admin-main {
    padding: 16px;
  }

  .admin-summary,
  .admin-view.is-active {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .span-2 {
    grid-column: auto;
  }

  .asset-grid,
  .compact-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .batch-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .batch-count {
    margin-left: 0;
    text-align: center;
  }

  .keyboard-hints .hint-item:not(:nth-child(-n+3)) {
    display: none;
  }

  .login-card {
    padding: 28px;
  }
}