:root {
  --bg: #0B0D12; --surface: #10131A; --surface-2: #151923; --control: #1A1F2B;
  --accent: #3D7BFF; --accent-hover: #5C90FF;
  --text: #EDEFF3; --text-dim: #9BA1AE; --silver: #C7CCD6;
  --line: rgba(199,204,214,0.10); --line-strong: rgba(199,204,214,0.18);
  --ok: #55B889; --warn: #DDAE52; --err: #E06C6C;
  --r-card: 12px; --r-control: 8px;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(61,123,255,0.55);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px; line-height: 1.5; padding-bottom: 56px;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
a { color: var(--accent); text-decoration: none; }

.topbar { display: flex; justify-content: space-between; align-items: center; height: 60px; padding: 0 32px; border-bottom: 1px solid var(--line); }
.topbar-left { display: flex; align-items: center; gap: 14px; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; }
.app-name { font-weight: 800; font-size: 15.5px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.nav-item { font-size: 13px; font-weight: 700; color: var(--text-dim); padding: 7px 14px; border-radius: var(--r-control); }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--text); background: rgba(61,123,255,0.10); }
.session { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); margin-left: 16px; padding-left: 20px; border-left: 1px solid var(--line); }
.session-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 32px 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.page-head h1 { font-weight: 800; font-size: 21px; }
.page-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 20px; box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 12px 32px rgba(0,0,0,0.28); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 8px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-weight: 700; font-size: 14px; }
.card-hint { font-size: 12.5px; color: var(--text-dim); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 700; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
tbody tr:hover td { background: rgba(255,255,255,0.015); }
.col-num { width: 44px; padding-left: 20px; color: var(--text-dim); font-size: 12.5px; }
.col-act { width: 84px; text-align: right; padding-right: 20px; }

.p-title { font-weight: 700; font-size: 13.5px; }
.p-url { font-size: 12px; color: var(--text-dim); margin-top: 2px; max-width: 430px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-url .src { color: var(--silver); }
.p-note { font-size: 12px; margin-top: 4px; }
.p-note.warn { color: var(--warn); }
.p-note.dim { color: var(--text-dim); }

.qty-input, .url-input, .select {
  background: var(--control); border: 1px solid var(--line-strong); border-radius: var(--r-control);
  height: 36px; padding: 0 12px; font-size: 13px;
}
.qty-input { width: 64px; text-align: center; font-weight: 700; }
.url-input { flex: 1; min-width: 0; }
.url-input::placeholder, .qty-input::placeholder { color: var(--text-dim); }
.qty-input:focus, .url-input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.select { min-width: 160px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: rgba(85,184,137,0.10); color: var(--ok); }
.pill-run { background: rgba(61,123,255,0.10); color: var(--accent); }
.pill-wait { background: rgba(155,161,174,0.10); color: var(--text-dim); }
.pill-warn { background: rgba(221,174,82,0.10); color: var(--warn); }
.pill-err { background: rgba(224,108,108,0.10); color: var(--err); }
.spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid rgba(61,123,255,0.25); border-top-color: var(--accent); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 18px; border-radius: var(--r-control); font-weight: 700; font-size: 13.5px; border: 1px solid transparent; transition: background 150ms ease-out, border-color 150ms ease-out; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--silver); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: rgba(199,204,214,0.35); color: var(--text); }
.btn-sm { height: 30px; padding: 0 13px; font-size: 12.5px; }
.btn:disabled { background: var(--control); color: var(--text-dim); border-color: var(--line); cursor: default; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.composer-row { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.composer-row:last-of-type { border-bottom: none; }
.add-row { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--surface-2); border-top: 1px solid var(--line); }

.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line); }
.legend { display: flex; align-items: center; gap: 16px; font-size: 12.5px; color: var(--text-dim); flex-wrap: wrap; }
.legend b { color: var(--text); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg .dot { width: 7px; height: 7px; border-radius: 50%; }
.lg-ok .dot { background: var(--ok); } .lg-run .dot { background: var(--accent); }
.lg-warn .dot { background: var(--warn); } .lg-err .dot { background: var(--err); }
.lg-wait .dot { background: var(--text-dim); }
.foot-note { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.upload { margin: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-control); padding: 12px 16px; background: var(--surface-2); font-size: 13px; color: var(--text-dim); }
.report { margin: 0 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.rgroup { border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden; }
.rhead { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px; font-weight: 700; font-size: 12.5px; }
.rhead .count { margin-left: auto; opacity: 0.8; }
.rhead-err { color: var(--err); background: rgba(224,108,108,0.06); }
.rhead-warn { color: var(--warn); background: rgba(221,174,82,0.06); }
.rhead-ok { color: var(--ok); background: rgba(85,184,137,0.06); }
.ritem { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.rloc { font-family: Consolas, monospace; font-size: 11.5px; background: var(--control); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; color: var(--silver); white-space: nowrap; }

.overlay { position: fixed; inset: 0; background: rgba(11,13,18,0.85); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card); padding: 28px; width: 400px; max-width: 92vw; max-height: 86vh; overflow: auto; }
.modal h2 { font-size: 16px; font-weight: 800; margin-bottom: 16px; }
.modal label { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin: 12px 0 4px; }
.modal input[type=text], .modal input[type=password], .modal input[type=number], .modal textarea, .modal select {
  width: 100%; background: var(--control); border: 1px solid var(--line-strong); border-radius: var(--r-control); padding: 9px 12px; font-size: 13px; color: var(--text);
}
.modal textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--accent); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.error-text { color: var(--err); font-size: 12.5px; margin-top: 8px; min-height: 18px; }

.batch-list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.batch-list-item:hover { background: rgba(255,255,255,0.015); }
.hidden { display: none !important; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.footer { max-width: 1120px; margin: 4px auto 0; padding: 14px 32px 0; display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); border-top: 1px solid var(--line); }

/* ---------- validation states ---------- */
.invalid, .invalid:focus { border-color: var(--err) !important; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(224,108,108,0.4) !important; }
.row-remove {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 17px; line-height: 1;
  transition: color 150ms ease-out, background 150ms ease-out, transform 150ms ease-out;
}
.row-remove:hover { color: var(--err); background: rgba(224,108,108,0.10); transform: scale(1.08); }
.btn-blocked { background: var(--control); color: var(--text-dim); cursor: not-allowed; }
.btn-blocked:hover { background: var(--control); }
.btn-deny { animation: deny 500ms ease-out; }
@keyframes deny {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); background: rgba(224,108,108,0.85); }
  40% { transform: translateX(5px); background: rgba(224,108,108,0.85); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---------- ambient background ---------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-glow { position: absolute; border-radius: 50%; filter: blur(50px); will-change: transform; }
.bg-glow1 {
  width: 55vmax; height: 55vmax; top: -22vmax; left: -12vmax;
  background: radial-gradient(circle, rgba(61,123,255,0.075) 0%, rgba(61,123,255,0) 62%);
  animation: drift1 52s ease-in-out infinite alternate;
}
.bg-glow2 {
  width: 48vmax; height: 48vmax; bottom: -20vmax; right: -14vmax;
  background: radial-gradient(circle, rgba(199,204,214,0.045) 0%, rgba(199,204,214,0) 60%);
  animation: drift2 67s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-8vmax, -5vmax, 0) scale(0.92); } }
.bg-grid {
  position: absolute; inset: -28px;
  background-image: radial-gradient(rgba(199,204,214,0.055) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, black 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, black 30%, transparent 75%);
  animation: gridDrift 120s linear infinite;
}
@keyframes gridDrift { to { transform: translate3d(28px, 28px, 0); } }

/* ---------- character & micro-interactions ---------- */
::selection { background: rgba(61,123,255,0.35); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--control); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(199,204,214,0.25); }

.btn:active:not(.btn-blocked):not(:disabled) { transform: scale(0.975); }
.btn { transition: background 150ms ease-out, border-color 150ms ease-out, transform 100ms ease-out; }

.logo path, .logo rect, .logo line { transition: transform 200ms ease-out; }
.logo:hover path { transform: translateX(2px); }

.modal { animation: modalIn 260ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
.overlay { animation: fadeIn 200ms ease-out; }
@keyframes fadeIn { from { opacity: 0; } }

#login-overlay .modal svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: arrowDraw 700ms 200ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
@keyframes arrowDraw { to { stroke-dashoffset: 0; } }

.card { animation: cardIn 300ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .bg-glow1, .bg-glow2, .bg-grid, .modal, .overlay, .card,
  #login-overlay .modal svg path, .btn-deny { animation: none; }
  #login-overlay .modal svg path { stroke-dashoffset: 0; }
}
