:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1c1f26; --muted: #6b7280; --line: #e2e5ea;
  --navy: #14213d; --accent: #2563eb; --ok: #15803d; --warn: #b45309; --fail: #b91c1c; --info: #475569;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(20,33,61,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
header#top { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 52px; background: var(--navy); color: #fff; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand .logo { display: inline-block; background: #fff; color: var(--navy); border-radius: 6px; padding: 0 6px; margin-right: 4px; font-size: 14px; }
#nav a { color: #cdd5e5; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
#nav a.active, #nav a:hover { color: #fff; background: rgba(255,255,255,.12); }
.spacer { flex: 1; }
#who { color: #cdd5e5; font-size: 13px; }
button.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; }
main { max-width: 1280px; margin: 0 auto; padding: 20px; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
label.f { display: block; margin: 8px 0; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=password], input[type=number], select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--fail); }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* drop zone */
.drop { border: 2px dashed #c7cdd8; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: #fafbfc; cursor: pointer; }
.drop.over { border-color: var(--accent); background: #eff6ff; color: var(--accent); }
.drop strong { color: var(--ink); }

/* items */
.items { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px #bfdbfe; }
.item img, .item canvas { width: 56px; height: 56px; object-fit: contain; background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 0/12px 12px; border-radius: 4px; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: var(--ok); } .badge.warn { background: #fef3c7; color: var(--warn); }
.badge.fail { background: #fee2e2; color: var(--fail); } .badge.info { background: #e2e8f0; color: var(--info); }
.badge.done { background: #dbeafe; color: #1e40af; }

/* preview */
.preview { position: relative; background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 0/20px 20px; border: 1px solid var(--line); border-radius: 8px; min-height: 320px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.preview canvas { max-width: 100%; max-height: 70vh; box-shadow: 0 2px 12px rgba(0,0,0,.25); background: #fff; }
.preview .dims { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: #334155; background: rgba(255,255,255,.85); padding: 2px 8px; border-radius: 6px; }
.checks { list-style: none; padding: 0; margin: 10px 0; }
.checks li { display: flex; gap: 8px; padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; }
.checks li.ok { background: #f0fdf4; } .checks li.warn { background: #fffbeb; } .checks li.fail { background: #fef2f2; } .checks li.info { background: #f8fafc; }
.checks .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.ok .dot { background: var(--ok); } .warn .dot { background: var(--warn); } .fail .dot { background: var(--fail); } .info .dot { background: var(--info); }
.progress { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
textarea.reject { height: 150px; font-size: 13px; }

/* history */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; }
.card img { width: 100%; aspect-ratio: 1.2; object-fit: contain; background: #f1f5f9; display: block; }
.card .b { padding: 8px 10px; }
.card .id { font-weight: 700; }
.card .sub { font-size: 12px; color: var(--muted); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal { background: #fff; border-radius: 12px; max-width: 900px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; }
.modal img { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto 12px; background: #f1f5f9; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 30; max-width: 90vw; }
#toast.err { background: var(--fail); }
.login { max-width: 360px; margin: 60px auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 500; }
