:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #185adb;
  --primary-dark: #1245a8;
  --green: #157347;
  --red: #b42318;
  --amber: #ad6f00;
  --shadow: 0 10px 30px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aab3c2;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

button.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

textarea {
  resize: vertical;
}

.sidebar {
  min-height: 100vh;
  background: #101828;
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #101828;
  font-weight: 800;
}

.brand span,
.status-box small {
  display: block;
  color: #cbd5e1;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #e5e7eb;
  border-color: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #1d2939;
  border-color: #344054;
  color: #fff;
}

.status-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #344054;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #182230;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--amber);
}

.dot.ok {
  background: #22c55e;
}

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

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

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

h1 {
  margin-bottom: 5px;
  font-size: 28px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 330px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: stretch;
}

.toolbar input {
  flex: 1;
}

.quick-create {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.quick-create h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.quick-create p {
  margin-bottom: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.list-panel,
.detail-panel,
.info-panel,
.user-card,
.review-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-head {
  display: grid;
  grid-template-columns: 1fr 90px 80px;
  gap: 10px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.product-list {
  display: grid;
}

.product-row {
  display: grid;
  grid-template-columns: 1fr 90px 80px;
  gap: 10px;
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  align-items: center;
}

.product-row.active {
  background: #eef4ff;
}

.product-name {
  display: grid;
  gap: 3px;
}

.product-name strong {
  overflow-wrap: anywhere;
}

.product-name small,
.history-item small {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef2f6;
  color: #344054;
}

.badge.Approved,
.badge.Sent {
  background: #dcfae6;
  color: #05603a;
}

.badge.Needs,
.badge.AI {
  background: #fff4d6;
  color: #8a5700;
}

.badge.Changes,
.badge.Rejected {
  background: #fee4e2;
  color: #912018;
}

.detail-panel {
  min-height: 620px;
  padding: 18px;
}

.empty-state {
  height: 420px;
  display: grid;
  place-content: center;
  text-align: center;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.action-row,
.language-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.image-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0 14px;
  min-height: 92px;
}

.image-strip a {
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-strip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.empty-images {
  align-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 56px;
}

.source-approval {
  display: grid;
  gap: 10px;
  border: 1px solid #f0c36a;
  background: #fff9eb;
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
}

.source-approval h3 {
  margin-bottom: 4px;
}

.source-approval p {
  margin-bottom: 0;
}

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

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
}

.tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

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

.confidence-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.history-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.section-title {
  margin-bottom: 16px;
}

.review-grid,
.users-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.review-card,
.user-card,
.info-panel {
  padding: 16px;
}

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

.permission-list label {
  grid-template-columns: 18px 1fr;
  display: grid;
  align-items: center;
  font-weight: 500;
}

.permission-list input {
  width: 18px;
  height: 18px;
}

.info-panel code {
  display: block;
  padding: 10px;
  margin: 8px 0;
  border-radius: 6px;
  background: #eef2f6;
  overflow-wrap: anywhere;
}

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

.source-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.source-list a {
  color: var(--primary);
  overflow-wrap: anywhere;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.mini-grid div,
.spec-list div,
.lookup-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.mini-grid span,
.spec-list span,
.lookup-list span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.spec-list,
.lookup-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.compact-fields {
  margin-bottom: 14px;
}

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

.flag-grid label {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 600;
}

.flag-grid input {
  width: 18px;
  height: 18px;
}

.specs-editor {
  margin-bottom: 14px;
}

.translation-toggle { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.translation-toggle input { width: auto; }
.translation-warning { padding: 12px; border-left: 3px solid #b36b00; background: #fff9e8; overflow-wrap: anywhere; }
body[aria-busy="true"]::after { content: 'Obrada artikla i prevoda je u toku...'; position: fixed; bottom: 20px; left: 20px; right: 20px; width: fit-content; max-width: calc(100% - 40px); padding: 14px; background: #15231f; color: white; border-radius: 6px; z-index: 1000; }

.product-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr));
  gap: 12px;
  margin: 16px 0;
}
.product-photo { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: white; }
.product-photo a { display: block; aspect-ratio: 1; padding: 12px; }
.product-photo img { width: 100%; height: 100%; object-fit: contain; }
.product-photo figcaption { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.image-resolution { width: 100%; font-size: 12px; color: #56616b; overflow-wrap: anywhere; }
.product-photo label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.product-photo input { width: auto; }
.product-photo .processed-label { font-size: 12px; color: #56616b; overflow-wrap: anywhere; }
.product-photo .text-button { width: auto; height: auto; min-height: 32px; padding: 6px 9px; font-size: 12px; justify-self: end; white-space: nowrap; }
.product-photo .icon-button { width: 32px; height: 32px; padding: 0; font-size: 20px; justify-self: end; }
.product-photo figcaption > .image-resolution { grid-column: 1 / -1; }
.description-preview { margin: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 18px 0; }
.description-preview summary { cursor: pointer; font-weight: 600; }
.description-preview article { max-width: 760px; line-height: 1.7; overflow-wrap: anywhere; padding: 16px 0; }
.description-preview h2 { font-size: 22px; line-height: 1.35; }
.description-preview h3 { font-size: 16px; margin: 24px 0 8px; }
.description-preview p { margin: 0 0 14px; }
.description-preview ul { padding-left: 22px; margin: 8px 0 16px; }
.description-preview li { padding: 3px 0; }
.preview-intro { color: #47545d; }

.manual-commercial {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.manual-commercial label {
  margin: 0;
}

.manual-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

.manual-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.manual-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f6f7f9;
  font-size: 12px;
}

.field-grid small,
.manual-commercial small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 720px;
  width: calc(100vw - 40px);
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.55);
}

.image-process-dialog {
  max-width: 920px;
}

.ai-preview-dialog {
  max-width: 1100px;
}

.ai-preview-dialog form {
  display: grid;
  gap: 14px;
}

.ai-preview-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.ai-preview-heading h2,
.ai-preview-heading p {
  margin: 0 0 6px;
}

.preview-count,
.preview-source span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f6f7f9;
  font-size: 12px;
  white-space: nowrap;
}

.preview-source {
  padding: 12px;
  border-left: 3px solid var(--primary);
  background: #f3f7ff;
  overflow-wrap: anywhere;
}

.preview-source span {
  margin-left: 10px;
}

.ai-preview-changes {
  display: grid;
  gap: 10px;
  max-height: min(66vh, 720px);
  overflow: auto;
}

.integration-comparison {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid #d8e1ec;
  border-radius: 14px;
  background: #f8fbff;
}

.integration-comparison .ai-preview-changes {
  max-height: 620px;
  overflow: auto;
}

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

.ai-change-select {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-change-select input {
  width: 18px;
  height: 18px;
}

.ai-change-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-change-values > div {
  min-width: 0;
}

.ai-change-values small {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

.ai-change-value {
  height: 100%;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-change-value.new {
  border-color: #91c6a8;
  background: #f1fbf5;
}

.ai-change-value p,
.ai-change-value ul,
.ai-change-value dl {
  margin: 0;
}

.ai-change-value dl div {
  display: grid;
  grid-template-columns: minmax(90px, .35fr) 1fr;
  gap: 8px;
  padding: 3px 0;
}

.ai-change-value dt {
  font-weight: 700;
}

.ai-change-value dd {
  margin: 0;
}

.ai-change-card footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.image-process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
  gap: 12px;
  max-height: min(62vh, 620px);
  overflow: auto;
  padding: 4px;
}

.image-process-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  min-width: 0;
}

.image-process-card input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
}

.image-process-preview {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, white 0% 50%) 0 / 16px 16px;
}

.image-process-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.image-process-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin-bottom: 0;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  background: #101828;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1000px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .ai-change-values {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar,
  .quick-create,
  .top-actions {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
}
[hidden] { display: none !important; }
.product-photo img { background: repeating-conic-gradient(#f0f0f0 0% 25%, white 0% 50%) 0 / 16px 16px; }
#categorySpecifications { margin-bottom: 20px; }
.quick-create label { min-width: 0; }
.quick-create select, .quick-create input[type="url"] { max-width: 100%; width: 100%; }
label:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
label > input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 16px; }
.image-process-grid .image-process-card { display: grid; grid-template-columns: 18px 1fr; align-items: start; }
.image-process-grid .image-process-card input { width: 18px; height: 18px; flex: 0 0 18px; }
 #readinessPanel { border-block: 1px solid #d5dadd; padding: 12px 0; margin: 16px 0; }
 .readiness-status { color: #9c322c; font-weight: 600; }
 .readiness-status.ready { color: #227144; }
 .readiness-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 4px 16px; }
 .readiness-list button { border: 0; background: transparent; text-align: left; width: 100%; white-space: normal; overflow-wrap: anywhere; padding: 8px; }
 .readiness-list button:hover { background: #eef4f0; }
