* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #18202a;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f6f8;
}

[hidden] {
  display: none !important;
}

a {
  color: #1f5f99;
  text-decoration: none;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  color: #fff;
  background: #243241;
}

.app-name,
.current-user {
  color: #fff;
  font-weight: 700;
}

.app-name {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 197px;
  height: 56px;
  flex: 0 0 auto;
}

.brand-logo img,
.login-brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-name span:last-child,
.current-user {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-product {
  color: #f59e0b;
}

.brand-separator {
  color: #cbd5e1;
}

.topbar-user {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.impersonation-link {
  color: #f59e0b;
  font-weight: 700;
}

.impersonation-link:hover {
  color: #fde68a;
}

.sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 240px;
  padding: 18px 12px;
  background: #ffffff;
  border-right: 1px solid #dbe2e8;
  overflow: visible;
}

.sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
  padding-right: 4px;
}

.sidebar a,
.nav-section {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
}

.sidebar a:hover {
  background: #eef4f8;
}

.nav-group {
  position: relative;
}

.submenu {
  display: none;
  position: fixed;
  z-index: 5;
  left: 220px;
  min-width: 190px;
  max-width: 260px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(24, 32, 42, 0.14);
}

.submenu::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -28px;
  width: 28px;
  content: "";
}

.nav-group:hover .submenu,
.nav-group:focus-within .submenu,
.submenu.is-open {
  display: block;
}

.submenu a {
  padding: 7px 10px;
  color: #405062;
  font-size: 14px;
  white-space: nowrap;
}

.nav-section {
  margin-top: 12px;
  color: #657282;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.content {
  min-height: 100vh;
  padding: 88px 32px 32px 272px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.sidebar-copyright {
  display: block;
  flex: 0 0 auto;
  margin-top: auto;
  padding: 10px 12px;
  color: #ffffff;
  background: #7a828c;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.sidebar-copyright span {
  display: block;
}

.sidebar .sidebar-copyright:hover {
  color: #ffffff;
  background: #727a84;
}

.login-card,
.panel {
  width: 100%;
  max-width: 960px;
  padding: 24px;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 32, 42, 0.08);
}

.login-card {
  max-width: 420px;
}

.login-brand {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  margin: -24px -24px 30px;
  padding: 0 24px;
  color: #ffffff;
  background: #243241;
  border-radius: 8px 8px 0 0;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

.login-brand-logo {
  display: block;
  width: 168px;
  height: 38px;
  flex: 0 0 auto;
}

h1 {
  margin: 0 0 20px;
  font-size: 28px;
}

h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #b8c3ce;
  border-radius: 6px;
  font: inherit;
}

input[type="file"] {
  padding: 8px;
  background: #fff;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.checkbox-row input {
  width: auto;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  background: #2f6f9f;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button.secondary,
.button.secondary {
  color: #18202a;
  background: #e7edf2;
}

button.danger,
.button.danger {
  background: #a83f3f;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #dbe2e8;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #dbe2e8;
}

th {
  color: #4f5f6f;
  background: #f8fafc;
  font-size: 13px;
}

.flash,
.error {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 6px;
}

.flash {
  background: #e9f6ee;
  border: 1px solid #b8e0c4;
}

.error {
  background: #fff0f0;
  border: 1px solid #e5b4b4;
}

.result-box h2 {
  margin: 0 0 12px;
}

.result-box p {
  white-space: pre-wrap;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.result-metrics div {
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(24, 32, 42, 0.1);
  border-radius: 6px;
}

.result-metrics strong,
.result-metrics span {
  display: block;
}

.result-metrics strong {
  font-size: 24px;
}

.result-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.export-group-list,
.export-context-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.export-group {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
}

.export-group > strong {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-group > .muted {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

.export-group ul {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
  padding-left: 18px;
}

.export-group li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.export-group li > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.export-original-group {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 3px solid #dbe2e8;
}

.export-original-group > strong {
  display: block;
  overflow: hidden;
  color: #243241;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #405062;
  background: #edf3f7;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.danger {
  color: #7b2d2d;
  background: #f7e7e7;
}

.loading-note {
  margin-top: 16px;
  padding: 12px;
  color: #405062;
  background: #f8fafc;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
}

.loading-note strong,
.loading-note span {
  display: block;
}

.loading-note span {
  margin-top: 4px;
}

.loading-inline {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  color: #405062;
  font-weight: 700;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d2dce5;
  border-top-color: #2f6f9f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-bar {
  height: 12px;
  margin: 18px 0;
  overflow: hidden;
  background: #e7edf2;
  border-radius: 999px;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: #2f6f9f;
  transition: width 0.25s ease;
}

.inline-error {
  white-space: pre-wrap;
}

.muted {
  color: #657282;
}

.notice {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.notice.warning {
  color: #68470d;
  background: #fff7e6;
  border: 1px solid #f0d39a;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
}

.toolbar-field {
  flex: 1;
  min-width: 180px;
  margin: 0;
}

.toolbar-field input,
.toolbar-field select {
  min-width: 0;
}

.toolbar-field span {
  display: block;
  margin-bottom: 6px;
}

.toolbar-small {
  flex: 0 0 150px;
  max-width: 150px;
}

.toolbar-product {
  flex: 1 1 260px;
  max-width: 420px;
}

.list-meta {
  margin-bottom: 14px;
  color: #657282;
  font-size: 14px;
}

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

.dashboard-card {
  min-width: 0;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 32, 42, 0.08);
}

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

.dashboard-card-head h2 {
  margin: 0;
}

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

.metric-grid div {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
}

.metric-grid strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.metric-grid span {
  display: block;
  margin-top: 4px;
  color: #657282;
  font-size: 13px;
}

.coverage-bar {
  height: 10px;
  margin: 16px 0;
  overflow: hidden;
  background: #e7edf2;
  border-radius: 999px;
}

.coverage-bar span {
  display: block;
  height: 100%;
  background: #2f6f9f;
}

.dashboard-card h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.image-list,
.image-tile-grid {
  display: grid;
  gap: 14px;
}

.image-tile-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.image-row,
.image-tile {
  display: grid;
  gap: 18px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
}

.image-row {
  grid-template-columns: 124px 1fr;
}

.image-tile {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.image-tile .thumb-wrap {
  width: 100%;
  height: 180px;
}

.image-tile .image-heading {
  display: block;
  min-height: 78px;
}

.image-tile .image-heading h2 {
  display: -webkit-box;
  min-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 1.25;
  font-size: 16px;
}

.thumb-wrap {
  display: grid;
  width: 124px;
  height: 92px;
  place-items: center;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
  cursor: zoom-in;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
}

.variant-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.image-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.image-heading > div {
  min-width: 0;
}

.image-heading h2 {
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.variant-count {
  padding: 5px 8px;
  color: #405062;
  white-space: nowrap;
  background: #edf3f7;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.language-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.language-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #243241;
  background: #e7edf2;
  border: 1px solid #d2dce5;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.image-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.variant-details {
  margin-top: 14px;
}

.variant-details summary {
  cursor: pointer;
  color: #1f5f99;
  font-weight: 700;
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.variant-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
}

.variant-item img {
  width: 64px;
  height: 54px;
}

.variant-thumb {
  display: grid;
  width: 64px;
  height: 54px;
  place-items: center;
  padding: 0;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
  cursor: zoom-in;
}

.variant-item span {
  display: block;
  margin-top: 4px;
  color: #657282;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.variant-actions,
.variant-delete-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.variant-delete-form button {
  margin: 0;
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.modal {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #dbe2e8;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(24, 32, 42, 0.22);
}

.modal-wide {
  width: min(760px, calc(100% - 32px));
}

.modal::backdrop {
  background: rgba(24, 32, 42, 0.38);
}

.lightbox {
  width: min(1100px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
}

.lightbox::backdrop {
  background: rgba(12, 18, 25, 0.78);
}

.lightbox figure {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 18px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.lightbox img {
  width: 100%;
  max-height: calc(100vh - 128px);
  object-fit: contain;
  background: #ffffff;
}

.lightbox figcaption {
  min-width: 0;
  overflow: hidden;
  color: #405062;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 1;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: #243241;
  background: #ffffff;
  border: 1px solid #dbe2e8;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-form {
  padding: 20px;
}

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

.modal-head h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 14px;
  margin: 14px 0 18px;
}

.info-grid span {
  color: #657282;
}

.info-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}

.json-box {
  max-height: 220px;
  padding: 12px;
  overflow: auto;
  color: #243241;
  background: #f8fafc;
  border: 1px solid #dbe2e8;
  border-radius: 6px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 14px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .app-name {
    gap: 8px;
  }

  .sidebar {
    position: static;
    width: auto;
    padding-top: 72px;
    border-right: 0;
    border-bottom: 1px solid #dbe2e8;
  }

  .content {
    padding: 24px 16px;
  }

  .actions {
    flex-wrap: wrap;
  }

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

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

  .dashboard-card-head,
  .metric-grid {
    display: block;
  }

  .dashboard-card-head .button,
  .metric-grid div {
    margin-top: 10px;
  }

  .toolbar,
  .image-row,
  .image-tile,
  .image-heading {
    display: block;
  }

  .image-tile-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-field,
  .toolbar-small {
    max-width: none;
    margin-bottom: 12px;
  }

  .thumb-wrap {
    width: 100%;
    height: 160px;
    margin-bottom: 14px;
  }

  .variant-count {
    display: inline-block;
    margin-top: 10px;
  }

  .variant-actions,
  .variant-delete-form {
    display: flex;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .result-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .login-brand-logo {
    width: 38px;
    height: 38px;
  }
}
