:root {
    --bg:        #0F1419;
    --surface:   #FFFFFF;
    --surface-2: #F4F6FA;
    --line:      #E2E6ED;
    --line-2:    #C9D0DC;
    --text:      #1F2937;
    --text-mute: #6B7280;
    --text-faint:#9CA3AF;
    --accent:    #034EA2;
    --accent-2:  #0A6FD9;
    --gold:      #C8A96E;
    --good:      #10A37F;
    --warn:      #C8A96E;
    --bad:       #E94B3C;
    --shadow-sm: 0 1px 2px rgba(10,22,40,.05);
    --shadow:    0 8px 28px rgba(10,22,40,.08);
    --shadow-lg: 0 22px 60px rgba(10,22,40,.18);
    --header:    62px;
    --left-w:    380px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}
button { font: inherit; cursor: pointer; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .9em;
    background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
}

/* ---------- Top bar ---------- */
.topbar {
    height: var(--header);
    background: linear-gradient(135deg, #0A1628 0%, #034EA2 100%);
    color: #fff;
    display: flex; align-items: center;
    padding: 0 22px;
    gap: 24px;
    position: sticky; top: 0; z-index: 5;
    box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 8px 24px rgba(10,22,40,.18);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.topbar__logo { width: 32px; height: 32px; color: var(--gold); flex-shrink: 0; }
.topbar__brand h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.topbar__sub { margin: 1px 0 0; font-size: 11.5px; color: rgba(255,255,255,.65); font-weight: 500; }
.topbar__sub #aiStatus.is-on { color: var(--gold); }
.topbar__sub #aiStatus.is-off { color: rgba(255,255,255,.5); }

.topbar__progress { flex: 1; display: flex; flex-direction: column; gap: 5px; max-width: 480px; }
.progress { background: rgba(255,255,255,.12); height: 6px; border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #E8D5AA); transition: width .35s ease; }
.progress__label { font-size: 11px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; letter-spacing: .2px; }

.topbar__actions { display: flex; gap: 8px; }
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 0;
    font-size: 13px; font-weight: 600;
    transition: background .15s ease, transform .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn svg { width: 14px; height: 14px; }
.btn--primary { background: var(--gold); color: #0A1628; }
.btn--primary:hover { background: #E8D5AA; transform: translateY(-1px); }
.btn--ghost { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.btn--ghost:hover { background: rgba(255,255,255,.16); }
.btn--secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn--secondary:hover { background: #E2E6ED; }
.btn--success { background: var(--good); color: #fff; }
.btn--success:hover { filter: brightness(1.08); }
.btn--danger-ghost { background: transparent; color: var(--bad); border: 1px solid rgba(233,75,60,.3); }
.btn--danger-ghost:hover { background: rgba(233,75,60,.08); }

/* ---------- Layout ---------- */
.layout {
    height: calc(100vh - var(--header));
    display: grid;
    grid-template-columns: var(--left-w) 1fr;
    gap: 0;
}

/* ---------- Left list ---------- */
.leftpane {
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.leftpane__filters {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line);
    display: grid; gap: 10px;
}
.search {
    width: 100%;
    padding: 9px 14px 9px 38px;
    background: var(--surface-2) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236B7280" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>') 12px 50% / 16px 16px no-repeat;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13.5px;
}
.search:focus { outline: 0; border-color: var(--accent); background-color: #fff; }
.select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 13px;
    color: var(--text);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 11px;
    font-size: 12px;
    font-weight: 500;
    transition: all .15s ease;
}
.chip:hover { border-color: var(--line-2); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.leftpane__list { flex: 1; overflow-y: auto; }
.product-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .12s ease;
    position: relative;
}
.product-row:hover { background: var(--surface-2); }
.product-row.is-selected { background: rgba(3,78,162,.06); border-left: 3px solid var(--accent); padding-left: 13px; }
.product-row__thumb {
    width: 56px; height: 56px;
    border-radius: 8px;
    background: var(--surface-2) center/contain no-repeat;
    border: 1px solid var(--line);
    flex-shrink: 0;
    position: relative;
}
.product-row__thumb--missing::after {
    content: "?";
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: var(--bad);
}
.product-row__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.product-row__title {
    font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-row__meta {
    font-size: 11.5px; color: var(--text-mute);
    display: flex; gap: 6px; align-items: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-row__cat-chip {
    display: inline-flex;
    background: rgba(3,78,162,.08); color: var(--accent);
    font-size: 10px; font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: .3px;
}
.product-row__status {
    position: absolute; top: 11px; right: 14px;
    font-size: 10px; font-weight: 700; letter-spacing: .3px;
    padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.status--review   { background: rgba(200,169,110,.14); color: #806120; }
.status--confirmed{ background: rgba(16,163,127,.12); color: var(--good); }
.status--changed  { background: rgba(110,69,226,.10); color: #5028C8; }
.leftpane__count { padding: 10px 16px; font-size: 11px; color: var(--text-faint); border-top: 1px solid var(--line); }

/* ---------- Right detail ---------- */
.rightpane { overflow-y: auto; padding: 22px 24px 60px; }
.placeholder { text-align: center; padding: 80px 32px; color: var(--text-mute); }
.placeholder h2 { font-size: 18px; color: var(--text); margin: 0 0 6px; }
.muted { color: var(--text-mute); font-size: 13px; }

.product-head {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start;
}
.product-head h2 { font-size: 20px; margin: 0 0 4px; line-height: 1.25; color: var(--text); }
.product-head .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tag {
    display: inline-flex; align-items: center;
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--text-mute); font-size: 11.5px; font-weight: 500;
    padding: 3px 9px; border-radius: 999px;
}
.tag.tag--review { background: rgba(200,169,110,.14); border-color: rgba(200,169,110,.3); color: #7E5F1A; }
.tag.tag--cat { background: rgba(3,78,162,.08); border-color: rgba(3,78,162,.2); color: var(--accent); font-weight: 600; }

.product-head__actions { display: flex; gap: 8px; flex-shrink: 0; }

.primary-slot {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
    display: grid; grid-template-columns: 320px 1fr; gap: 24px;
    box-shadow: var(--shadow-sm);
}
.primary-img-wrap {
    position: relative;
    aspect-ratio: 1/1;
    background: var(--surface-2);
    border-radius: 12px;
    border: 2px dashed var(--line-2);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s ease, background .2s ease;
}
.primary-img-wrap.is-dragover {
    border-color: var(--accent);
    background: rgba(3,78,162,.06);
    border-style: solid;
}
.primary-img-wrap img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.primary-img-wrap__empty { color: var(--text-faint); font-size: 13px; padding: 24px; text-align: center; }
.primary-img-wrap__filename {
    position: absolute; bottom: 8px; left: 8px; right: 8px;
    background: rgba(10,22,40,.78); color: #fff;
    padding: 4px 10px; border-radius: 6px; font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.primary-side { display: flex; flex-direction: column; gap: 14px; }
.primary-side h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text-mute); }
.gallery-strip { display: flex; gap: 8px; flex-wrap: wrap; min-height: 70px;
    padding: 10px;
    background: var(--surface-2);
    border-radius: 10px;
    border: 1px dashed var(--line-2);
    transition: border-color .2s ease, background .2s ease;
}
.gallery-strip.is-dragover { border-color: var(--accent); background: rgba(3,78,162,.06); border-style: solid; }
.gallery-strip__empty { color: var(--text-faint); font-size: 12px; padding: 18px; text-align: center; flex: 1; }
.gallery-thumb {
    width: 64px; height: 64px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface) center/contain no-repeat;
    position: relative;
    cursor: grab;
    flex-shrink: 0;
}
.gallery-thumb:active { cursor: grabbing; }
.gallery-thumb__del {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--bad); color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; line-height: 1;
    border: 0; padding: 0;
}
.gallery-thumb:hover .gallery-thumb__del { display: flex; }

.suggest-row {
    display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
}
.suggest-row__btns { display: flex; gap: 6px; }

/* ---------- Suggestions list ---------- */
.suggestions {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 18px 20px; margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.suggestions__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.suggestions__head h3 { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text-mute); }
.suggestions__head .badge {
    font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600;
}
.badge--ai { background: linear-gradient(90deg, var(--accent), #6E45E2); color: #fff; }
.badge--heuristic { background: var(--surface-2); color: var(--text-mute); border: 1px solid var(--line); }
.suggestions__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.suggest-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
    display: flex; flex-direction: column; gap: 4px;
    position: relative;
}
.suggest-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.suggest-card__img {
    width: 100%; aspect-ratio: 1; background: #fff center/contain no-repeat;
    border-radius: 6px; border: 1px solid var(--line);
}
.suggest-card__score {
    position: absolute; top: 12px; right: 12px;
    background: rgba(10,22,40,.85); color: #fff;
    font-size: 11px; font-weight: 700;
    padding: 2px 7px; border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}
.suggest-card__name { font-size: 11.5px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 4px 0; }
.suggest-card__reason { font-size: 11px; color: var(--text-faint); padding: 0 4px; line-height: 1.4; max-height: 2.8em; overflow: hidden; }

/* ---------- Full gallery ---------- */
.gallery-section {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.gallery-section__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.gallery-section__head h3 { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text-mute); }
.gallery-section__filters { display: flex; gap: 6px; align-items: center; }
.search--small {
    padding: 5px 10px 5px 30px;
    font-size: 12px;
    background-position: 8px 50%; background-size: 13px 13px;
    border-radius: 6px;
    width: 200px;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 600px; overflow-y: auto;
    padding-right: 4px;
}
.image-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    cursor: grab;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
    position: relative;
}
.image-card:active { cursor: grabbing; }
.image-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.image-card__img { width: 100%; aspect-ratio: 1; background: #fff center/contain no-repeat; border-bottom: 1px solid var(--line); }
.image-card__caption { padding: 5px 8px; font-size: 11px; color: var(--text-mute); display: flex; flex-direction: column; gap: 1px; }
.image-card__filename { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-card__path { font-size: 10px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-card.in-use { outline: 2px solid var(--good); }
.image-card .in-use-badge {
    position: absolute; top: 6px; right: 6px;
    background: var(--good); color: #fff; font-size: 9px; font-weight: 700;
    padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: .3px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text); color: #fff;
    padding: 12px 20px; border-radius: 10px;
    font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 100;
    max-width: 460px;
}
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast--success { background: var(--good); }
.toast--error { background: var(--bad); }

/* ---------- Mobile / responsive ---------- */
@media (max-width: 1100px) {
    :root { --left-w: 320px; }
    .primary-slot { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .layout { grid-template-columns: 1fr; }
    .leftpane { display: none; height: 100%; }
    .leftpane.is-open { display: flex; }
    .rightpane { padding: 14px; }
    .topbar__progress { display: none; }
}

/* ---------- Drag indicators ---------- */
.is-dragging * { cursor: grabbing !important; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    background: linear-gradient(135deg, #0A1628 0%, #034EA2 60%, #0A6FD9 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    overflow-y: auto;
    padding: 24px;
}
.login-body::before {
    content: "";
    position: fixed; inset: 0;
    background:
      radial-gradient(circle at 85% 20%, rgba(200,169,110,0.25), transparent 40%),
      radial-gradient(circle at 10% 90%, rgba(10,111,217,0.30), transparent 50%);
    pointer-events: none;
}
.login-shell {
    width: 100%;
    max-width: 380px;
    position: relative;
    z-index: 1;
}
.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 40px 36px;
    box-shadow: 0 30px 80px rgba(10,22,40,.35);
}
.login-card__head { text-align: center; margin-bottom: 26px; }
.login-card__logo {
    width: 44px; height: 44px;
    color: var(--accent);
    margin-bottom: 14px;
}
.login-card__head h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text);
}
.login-card__head p { font-size: 13.5px; color: var(--text-mute); margin: 0; }
.login-form { display: grid; gap: 12px; }
.login-form label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.login-form input[type="password"] {
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(3,78,162,.12);
}
.login-error {
    margin-top: 6px;
    padding: 10px 14px;
    background: rgba(233,75,60,.08);
    border: 1px solid rgba(233,75,60,.30);
    border-radius: 8px;
    color: var(--bad);
    font-size: 13px;
    text-align: left;
}
.login-foot {
    margin-top: 22px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-faint);
}

@media (max-width: 480px) {
    .login-card { padding: 32px 24px; }
}
