.dm-page {
  --dm-card: #121218;
  --dm-card-2: #181820;
  --dm-line: rgba(255,255,255,0.07);
  --dm-green: #2ecc71;
}

.dm-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

.dm { padding-bottom: 80px; }

.dm-hero {
  position: relative;
  padding: 44px 0 36px;
  background:
    radial-gradient(circle at 85% -20%, rgba(229,9,20,0.28), transparent 55%),
    radial-gradient(circle at 10% 120%, rgba(245,197,24,0.1), transparent 50%);
  border-bottom: 1px solid var(--dm-line);
  margin-bottom: 26px;
}
.dm-hero-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; }
.dm-title { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1 1 380px; }
.dm-logo {
  flex: 0 0 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--red-bright), #9d0610);
  color: #fff;
  box-shadow: 0 14px 34px rgba(229,9,20,0.35);
}
.dm-logo svg { width: 28px; height: 28px; }
.dm-title h1 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.2; }
.dm-title p { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

.dm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--dm-line);
  border: 1px solid var(--dm-line);
  border-radius: 16px;
  overflow: hidden;
  min-width: min(100%, 460px);
}
.dm-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: rgba(14,14,20,0.9); }
.dm-stats span { font-size: 11.5px; color: var(--text-faint); }
.dm-stats strong { font-size: 18px; font-weight: 800; text-align: right; white-space: nowrap; }
#dmSpeed { color: var(--dm-green); }

.dm-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.dm-toolbar-group { display: flex; flex-wrap: wrap; gap: 8px; }
.dm-toolbar .btn { padding: 10px 16px; font-size: 13.5px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.dm-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 13px 16px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: rgba(52,152,219,0.1);
  border: 1px solid rgba(52,152,219,0.28);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.9;
}
.dm-notice strong { color: var(--text); }
.dm-notice .btn { margin-inline-start: auto; }
.dm-notice-warn { background: rgba(245,197,24,0.08); border-color: rgba(245,197,24,0.3); }

.dm-panel {
  background: var(--dm-card);
  border: 1px solid var(--dm-line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 18px;
}
.dm-panel h2 { font-size: 18px; margin-bottom: 14px; }
.dm-add-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.dm-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); font-weight: 600; flex: 1 1 200px; }
.dm-field-wide { flex: 3 1 340px; }
.dm-field b { color: var(--text); }
.dm-field input[type="url"], .dm-field input[type="text"], .dm-field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--dm-line);
  border-radius: 11px;
  padding: 11px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}
.dm-field select:disabled { opacity: 0.6; }
.dm-field input:focus, .dm-field select:focus { outline: none; border-color: var(--red); }
.dm-field input[type="range"] { accent-color: var(--red); width: 100%; }
.dm-hint { margin-top: 10px; font-size: 12.5px; color: var(--text-faint); }

.dm-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; margin-bottom: 18px; }
.dm-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 20px; }
.dm-switch { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; }
.dm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.dm-switch span {
  position: relative;
  flex: 0 0 38px;
  height: 22px;
  border-radius: 22px;
  background: rgba(255,255,255,0.14);
  transition: background 0.2s;
}
.dm-switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.dm-switch input:checked + span { background: var(--red); }
.dm-switch input:checked + span::after { transform: translateX(-16px); }
.dm-switch input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }

.dm-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px; }
.dm-filters .chip { flex: 0 0 auto; font-family: inherit; cursor: pointer; }

.dm-list { display: flex; flex-direction: column; gap: 12px; }

.dm-item {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--dm-card);
  border: 1px solid var(--dm-line);
  transition: border-color 0.2s;
}
.dm-item[data-status="active"] { border-color: rgba(229,9,20,0.35); }
.dm-item[data-status="done"] { border-color: rgba(46,204,113,0.25); }
.dm-item[data-status="error"] { border-color: rgba(255,107,115,0.35); }
.dm-item-main { display: flex; align-items: center; gap: 14px; }
.dm-item-icon {
  flex: 0 0 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: rgba(229,9,20,0.12);
  color: var(--red-bright);
}
.dm-item[data-status="done"] .dm-item-icon { background: rgba(46,204,113,0.14); color: #4fd97f; }
.dm-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-item-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.dm-item-sub { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dm-badge { flex: 0 0 auto; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dm-badge-active { background: rgba(229,9,20,0.15); color: #ff6b73; }
.dm-badge-queued { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.dm-badge-paused { background: rgba(245,197,24,0.12); color: var(--gold); }
.dm-badge-done { background: rgba(46,204,113,0.14); color: #4fd97f; }
.dm-badge-error { background: rgba(229,9,20,0.18); color: #ff9ba0; }

.dm-item-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.dm-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  transition: background 0.2s, color 0.2s;
}
.dm-icon-btn svg { width: 17px; height: 17px; }
.dm-icon-btn:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.dm-icon-btn[data-act="start"], .dm-icon-btn[data-act="retry"] { background: rgba(229,9,20,0.16); color: #ff6b73; }
.dm-danger:hover { background: rgba(229,9,20,0.2); color: #ff6b73; }
.dm-icon-btn[hidden] { display: none; }

.dm-progress {
  position: relative;
  height: 10px;
  margin: 14px 0 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}
.dm-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, #b3050d, var(--red-bright));
  transition: width 0.4s ease;
}
.dm-item[data-status="done"] .dm-progress-fill { background: linear-gradient(90deg, #1e8f4e, var(--dm-green)); }
.dm-item[data-status="paused"] .dm-progress-fill, .dm-item[data-status="paused"] .dm-segments span { background: var(--gold); }
.dm-segments { position: absolute; inset: 0; }
.dm-segments span {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--red);
  border-left: 1px solid rgba(0,0,0,0.35);
  transition: width 0.4s ease;
}
.dm-segments span.is-busy {
  background: linear-gradient(90deg, var(--red), var(--red-bright), var(--red));
  background-size: 200% 100%;
  animation: dmFlow 1.2s linear infinite;
}
@keyframes dmFlow { from { background-position: 200% 0; } to { background-position: 0 0; } }

.dm-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; font-size: 12.5px; color: var(--text-faint); }
.dm-item-meta span:empty { display: none; }
.dm-item-meta [data-ref="percent"] { color: var(--text); font-weight: 800; }
.dm-item-meta [data-ref="speed"] { color: var(--dm-green); font-weight: 700; }
.dm-item-error { color: #ff9ba0; }
.dm-item-pass code { background: rgba(255,255,255,0.08); padding: 1px 8px; border-radius: 6px; color: var(--text); }
.dm-link { background: none; color: var(--red-bright); font-size: 12.5px; font-weight: 700; padding: 0 4px; }

.dm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 50px 20px;
  text-align: center;
  color: var(--text-faint);
  border: 1px dashed var(--dm-line);
  border-radius: 18px;
}
.dm-empty[hidden], .dm-item[hidden], .dm-panel[hidden] { display: none; }
.dm-empty > span { font-size: 42px; }
.dm-empty strong { color: var(--text); font-size: 17px; }
.dm-empty .btn { margin-top: 8px; }

.dm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 300;
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 12px 20px;
  border-radius: 12px;
  background: #1d1d26;
  border: 1px solid var(--dm-line);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.dm-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.dm-toast-ok { border-color: rgba(46,204,113,0.4); }
.dm-toast-error { border-color: rgba(229,9,20,0.5); color: #ff9ba0; }

@media (max-width: 760px) {
  .dm-wrap { padding: 0 16px; }
  .dm-hero { padding: 28px 0 24px; }
  .dm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; width: 100%; }
  .dm-toolbar, .dm-toolbar-group { width: 100%; }
  .dm-toolbar-group .btn { flex: 1 1 auto; justify-content: center; }
  .dm-item { padding: 14px; }
  .dm-item-main { flex-wrap: wrap; gap: 10px 12px; }
  .dm-item-icon { flex-basis: 42px; height: 42px; }
  .dm-item-info { flex: 1 1 calc(100% - 140px); }
  .dm-item-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
}
