:root {
  --ink: #1c2230;
  --muted: #5b6475;
  --paper: #f3f5f8;
  --panel: #ffffff;
  --line: #d3d9e2;
  --accent: #0e6b72;
  --accent-ink: #ffffff;
  --danger: #a3262a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.45;
}
* { box-sizing: border-box; }
/* The UI shows and hides views with the hidden attribute; it must beat display rules such as .login { display: grid }. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

button, input, textarea { font: inherit; color: inherit; }
button {
  padding: .45rem .8rem; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.quiet { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .45; cursor: default; }
input[type="text"], input[type="search"], input[type="password"], input:not([type]), textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 1px; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
#status { margin: 0; padding: .4rem 1.25rem; min-height: 2rem; font-size: .9rem; color: var(--muted); }
#status.error { color: var(--danger); }

.split { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1rem; padding: 0 1.25rem 1.25rem; align-items: start; }
.list, .detail { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; }
.list ul { list-style: none; margin: .75rem 0; padding: 0; }
.row-btn { display: grid; grid-template-columns: 40px 1fr; gap: .1rem .7rem; width: 100%; padding: .4rem; text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.row-btn[aria-current="true"] { background: color-mix(in srgb, var(--accent) 10%, white); }
.row-btn .thumb { grid-row: span 2; width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--paper); }
.sku { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; letter-spacing: .01em; }
.name { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); }

.dhead h2 { font-size: 1.6rem; }
.dhead p { margin: .2rem 0 1rem; color: var(--muted); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.empty { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin-top: 0; }

.locales { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.locale { border: 1px solid var(--line); border-radius: 8px; padding: .9rem; display: grid; gap: .6rem; align-content: start; }
.field label { display: block; font-size: .9rem; margin-bottom: .2rem; }

.upload { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.images { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.images li { display: grid; gap: .4rem; align-content: start; }
.images img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--paper); }
.images .badge { font-size: .85rem; color: var(--accent); font-weight: 600; }
.images .badge.off { color: var(--danger); }
.images li.img-disabled img { opacity: .35; filter: grayscale(1); }
.images li.img-primary img { outline: 3px solid var(--accent); outline-offset: -3px; }
.img-type { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.img-type select { flex: 1; font: inherit; color: var(--ink); padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.images .btns { display: flex; flex-wrap: wrap; gap: .3rem; }
.images .btns button { padding: .25rem .5rem; font-size: .85rem; }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; width: min(520px, 92vw); }
dialog::backdrop { background: rgb(28 34 48 / .45); }
dialog form { display: grid; gap: .7rem; }
dialog .row { display: flex; gap: .5rem; }
.check { display: flex; gap: .5rem; align-items: center; }
#import-report ul { margin: .3rem 0 0; padding-left: 1.2rem; max-height: 220px; overflow: auto; }
#import-report .bad { color: var(--danger); }

.views { display: flex; gap: .25rem; }
.views button { background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; font-weight: 600; font-size: 1.05rem; }
.views button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.check.small { font-size: .9rem; color: var(--muted); margin-top: .5rem; }
.filter { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; color: var(--muted); }
.filter select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.small { font-size: .9rem; }

/* Product list: status and language chips */
.row-btn .langs { grid-column: 2; display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .15rem; }
.row-btn .langs.none { font-size: .75rem; color: var(--muted); }
.lang { font-size: .7rem; font-weight: 700; letter-spacing: .03em; line-height: 1; padding: .2rem .35rem; border-radius: 4px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.lang.partial { background: transparent; color: var(--accent); }
.flag { margin-left: .4rem; font-family: system-ui, sans-serif; font-size: .7rem; font-weight: 700; padding: .15rem .35rem; border-radius: 4px; vertical-align: .1em; }
.archived-flag { background: color-mix(in srgb, var(--danger) 12%, white); color: var(--danger); border: 1px solid var(--danger); }
.row-btn.is-archived .name { text-decoration: line-through; }
.row-btn .thumb { grid-row: span 3; }

/* Translations: the default-language column is read-only */
.locale.source { background: var(--paper); }
.locale.source .label { display: block; font-size: .9rem; margin-bottom: .2rem; color: var(--muted); }
.source-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12rem; overflow: auto; }
.archived { color: var(--danger); font-size: .9rem; }
.group { margin-bottom: 1.2rem; }
.group h3 { margin-bottom: .5rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); }

.page { padding: 0 1.25rem 1.25rem; }
.tax-group > h2 { font-size: 1.1rem; margin: 1.2rem 0 .6rem; }
.tax { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.tax h3 { margin-bottom: .6rem; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { color: var(--muted); font-weight: 600; }
tbody th { font-weight: 500; }
td input[type="text"] { min-width: 9rem; padding: .3rem .45rem; }
td button { padding: .3rem .6rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#sync-dialog { width: min(860px, 94vw); }
.dialog-body { display: grid; gap: .7rem; }
.dialog-body .row, dialog .row { flex-wrap: wrap; }
#sync-report .scroll { max-height: 50vh; overflow: auto; }
#sync-report .bad, #settings-report .bad { color: var(--danger); }
.ok { color: var(--accent); font-weight: 600; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; display: grid; gap: .8rem; }
.login-card h1 { font-size: 1.3rem; }
.login-card .hint { margin: 0; }
.bad { color: var(--danger); }
#login-error:empty, #password-report:empty, #users-report:empty { display: none; }
.who { align-self: center; font-size: .9rem; color: var(--muted); padding-left: .5rem; border-left: 1px solid var(--line); }
#users-dialog { width: min(680px, 94vw); }
#users-list .btns { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
#users-list .badge { color: var(--muted); font-weight: 400; }
form.inline { display: flex; gap: .3rem; }
form.inline input { min-width: 10rem; padding: .3rem .45rem; }
.user-form { display: grid; gap: .6rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.user-form h4 { margin: 0; font-size: .95rem; }
.user-section { display: grid; gap: .6rem; padding: 1rem 0; border-top: 2px solid var(--line); }
.user-section .hint { margin: 0; }
.new-key { border: 2px solid var(--accent); border-radius: 8px; padding: .8rem; display: grid; gap: .5rem; background: color-mix(in srgb, var(--accent) 6%, white); }
.new-key p { margin: 0; }
.key-row { display: flex; gap: .4rem; }
.key-row input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; }

/* Images page */
#view-images .tax > h2, .section-head h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: 1.25rem; margin-bottom: 1rem; border: 2px dashed var(--line); border-radius: 8px; background: var(--paper); }
.dropzone label { font-weight: 600; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, white); }
#bulk-report .scroll { max-height: 40vh; overflow: auto; }
#unassigned .file-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#unassigned form.inline input { min-width: 0; }
#unassigned li > button { padding: .3rem .6rem; font-size: .85rem; justify-self: start; }
/* Selecting unmatched images: a checkbox on each card, and a toolbar that stays in view */
.bulk-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .75rem; margin-bottom: 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.bulk-bar .check { font-weight: 600; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.bulk-actions input { width: 12rem; padding: .35rem .5rem; }
.bulk-actions button { padding: .35rem .7rem; }
#unassigned .pick { position: relative; display: block; cursor: pointer; }
#unassigned .pick input { position: absolute; top: .4rem; left: .4rem; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
#unassigned li.picked img { outline: 3px solid var(--accent); outline-offset: -3px; }

/* API page */
.api-split { display: grid; grid-template-columns: minmax(320px, 2fr) 3fr; gap: 1rem; align-items: start; }
.api-split > section { min-width: 0; }
.api-split h2 { font-size: 1.1rem; margin-bottom: .6rem; }
#api-form { display: grid; gap: .6rem; }
#api-form select { width: 100%; font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
#api-form input[type="number"] { width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font: inherit; }
#api-form .field label { color: var(--muted); }
#api-form .field label code { color: var(--ink); font-weight: 600; }
#api-form .check .hint { margin: 0; }
#api-description, #api-params .hint { margin: 0; }
#api-params { display: grid; gap: .6rem; }
.api-url { margin: 0; padding: .5rem .6rem; background: var(--paper); border-radius: 6px; overflow-wrap: anywhere; font-size: .9rem; }
.api-url .method { font-weight: 700; color: var(--accent); margin-right: .3rem; }
.api-sub { margin: 1.2rem 0 .4rem; }
.code-box { position: relative; }
.code-box pre, pre.raw { margin: 0; padding: .8rem; background: var(--ink); color: #e6ebf2; border-radius: 6px; overflow: auto; font-size: .82rem; line-height: 1.5; }
pre.raw { max-height: 65vh; white-space: pre-wrap; overflow-wrap: anywhere; }
#api-copy { position: absolute; top: .4rem; right: .4rem; padding: .2rem .55rem; font-size: .8rem; background: var(--panel); }
.api-status { margin: 0 0 .6rem; font-size: .9rem; color: var(--muted); }
.code-pill { font-weight: 700; padding: .15rem .45rem; border-radius: 4px; }
.ok-pill { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, white); }
.bad-pill { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, white); }

/* Response trees: one colour per JSON type */
.tree { font-size: .88rem; max-height: 65vh; overflow: auto; }
.tree details > summary, .tree .leaf { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem; padding: .15rem 0; }
.tree details > summary { cursor: pointer; list-style-position: outside; display: list-item; }
.tree details > summary > * { margin-right: .35rem; }
.tree .kids { margin-left: .5rem; padding-left: .9rem; border-left: 1px solid var(--line); }
.tree .key { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }
.tree .key.root { font-family: inherit; color: var(--muted); }
.tree .val { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: .82rem; }
.examples { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.opt { font-size: .72rem; font-style: italic; color: var(--muted); }
.type { font-size: .7rem; font-weight: 700; letter-spacing: .02em; padding: .08rem .35rem; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.t-string { color: #1d6b3a; }
.t-number { color: #1f4fa8; }
.t-boolean { color: #8a4a00; }
.t-null { color: #6b7280; }
.t-object { color: #7a2f8f; }
.t-array { color: #0e6b72; }
.v-string { color: #1d6b3a; }
.v-number { color: #1f4fa8; }
.v-boolean { color: #8a4a00; }
.v-null { color: #6b7280; font-style: italic; }
.api-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; vertical-align: middle; }
.csv-rows { max-height: 60vh; overflow: auto; }
.csv-rows td, .csv-rows th { white-space: nowrap; max-width: 24rem; overflow: hidden; text-overflow: ellipsis; }

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

@media (max-width: 800px) {
  .bar { flex-direction: column; align-items: stretch; }
  .split { grid-template-columns: 1fr; }
  .upload { grid-template-columns: 1fr; }
}
